package com.feiyu.universal.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.feiyu.universal.entity.Role;
import com.feiyu.universal.service.RoleService;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tang ming
 * @since 2021-11-30
 */
@RestController
@RequestMapping("/role")
@AllArgsConstructor
public class RoleController {

    private RoleService roleService;

    @GetMapping("/detail/{id}")
    public R<Role> detail(@PathVariable int id){
        return R.data(roleService.getById(id));
    }

    @GetMapping("/page")
    public R<Page<Role>> page(Page<Role> page){
        return R.data(roleService.page(page));
    }

    @PostMapping("/save")
    public R save(@RequestBody Role role){
        return R.status(roleService.save(role));
    }

    @PostMapping("/update")
    public R update(@RequestBody Role role){
        return R.status(roleService.updateById(role));
    }

    @PostMapping("/delete/{id}")
    public R delete(@PathVariable int id){
        return R.status(roleService.removeById(id));
    }
}

